home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / AppsToGo / AppsToGo.src / DTS.StyleChat / WindowDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  8.8 KB  |  370 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        WindowDialog.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19.  
  20.  
  21. /*****************************************************************************/
  22.  
  23.  
  24.  
  25. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  26. #include "App.defs.h"        /* Get various application definitions.            */
  27. #include "App.protos.h"        /* Get the prototypes for application.            */
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __UTILITIES__
  34. #include "Utilities.h"
  35. #endif
  36.  
  37.  
  38.  
  39. /*****************************************************************************/
  40.  
  41.  
  42.  
  43. extern RgnHandle    gCursorRgn;                /* We handle cursors here, so we need */
  44. extern CursPtr        gCursorPtr;                /* to know about these things. */
  45.                                             /* Above are DTS.Lib..framework globals. */
  46.  
  47. extern short        gDialogErr;                /* Error numbers to be displayed in   */
  48.                                             /* a dialog window of type 'ERR#' are */
  49.                                             /* passed in this way.                  */
  50.  
  51. static short    gCtlNum;
  52.  
  53.  
  54.  
  55. /*****************************************************************************/
  56. /*****************************************************************************/
  57.  
  58.  
  59.  
  60. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  61. /* See CalcFrameRgn() for info. */
  62.  
  63. #pragma segment TheDoc
  64. void    DialogCalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn)
  65. {
  66. #pragma unused (frHndl, window, rgn)
  67. }
  68.  
  69.  
  70.  
  71. /*****************************************************************************/
  72.  
  73.  
  74.  
  75. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  76. /* See ContentClick() for info. */
  77.  
  78. #pragma segment TheDoc
  79. void    DialogContentClick(WindowPtr window, EventRecord *event, Boolean firstClick)
  80. {
  81. #pragma unused (firstClick)
  82.  
  83.     short            cnum, action;
  84.     ControlHandle    ctl;
  85.  
  86.     gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
  87.     if ((cnum == -1) || (cnum == -2))
  88.         if (GetButtonVariant(ctl) == pushButProc)
  89.             DisposeOneWindow(window, kClose);
  90.  
  91.     return;
  92. }
  93.  
  94.  
  95.  
  96. /*****************************************************************************/
  97.  
  98.  
  99.  
  100. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  101. /* See ContentKey() for info. */
  102.  
  103. #pragma segment TheDoc
  104. Boolean    DialogContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough)
  105. {
  106. #pragma unused (passThrough)
  107.  
  108.     short            cnum, action;
  109.     ControlHandle    ctl;
  110.  
  111.     gCtlNum = cnum = IsCtlEvent(window, event, &ctl, &action);
  112.     if ((cnum == -1) || (cnum == -2)) {
  113.         if (GetButtonVariant(ctl) == pushButProc) {
  114.             DisposeOneWindow(window, kClose);
  115.             return(true);
  116.         }
  117.     }
  118.  
  119. #if DEV_VERSION
  120.     if ((event->message & charCodeMask) == (unsigned char)'≥') {
  121.         if ((event->modifiers & (optionKey | cmdKey)) == (optionKey | cmdKey)) {
  122.             gCtlNum = -2;
  123.             DisposeOneWindow(window, kClose);
  124.         }
  125.     }
  126. #endif
  127.  
  128.     return(true);
  129. }
  130.  
  131.  
  132.  
  133. /*****************************************************************************/
  134.  
  135.  
  136.  
  137. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  138. /* See DrawFrame() for info. */
  139.  
  140. #pragma segment TheDoc
  141. void    DialogDrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate)
  142. {
  143.     MoveTo(0, (*frHndl)->fileState.topSidebar - 1);
  144.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, (*frHndl)->fileState.topSidebar - 1);
  145.     LineTo((*frHndl)->fileState.leftSidebar - 1 - 16384, 16383);
  146.  
  147.     BeginFrame(window);
  148.     DoDrawControls(window, activate);
  149.     EndFrame(window);
  150. }
  151.  
  152.  
  153.  
  154. /*****************************************************************************/
  155.  
  156.  
  157.  
  158. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  159. /* See FreeDocument() for info. */
  160.  
  161. #pragma segment TheDoc
  162. OSErr    DialogFreeDocument(FileRecHndl frHndl)
  163. {
  164.     return(DefaultFreeDocument(frHndl));
  165. }
  166.  
  167.  
  168.  
  169. /*****************************************************************************/
  170.  
  171.  
  172.  
  173. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  174. /* See FreeWindow() for info. */
  175.  
  176. #pragma segment TheDoc
  177. OSErr    DialogFreeWindow(FileRecHndl frHndl, WindowPtr window)
  178. {
  179. #pragma unused (frHndl, window)
  180.  
  181. /* For dialogs that need to keep their info before getting dismissed:
  182. **   Check gCtlNum to see what control caused dialog dismissal.
  183. **     -1: Default button.
  184. **     -2: Cancel button.
  185. **   If you determine that the dialog shouldn't be dismissed after all, then
  186. **   return an error.
  187. */
  188.  
  189.     return(noErr);
  190. }
  191.  
  192.  
  193.  
  194. /*****************************************************************************/
  195.  
  196.  
  197.  
  198. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  199. /* See ImageDocument() for info. */
  200.  
  201. #pragma segment TheDoc
  202. OSErr    DialogImageDocument(FileRecHndl frHndl)
  203. {
  204. #pragma unused (frHndl)
  205.  
  206.     WindowPtr    curPort;
  207.  
  208.     GetPort(&curPort);
  209.     DoDrawControls(curPort, false);            /* Draw the content controls. */
  210.  
  211.     return(noErr);
  212. }
  213.  
  214.  
  215.  
  216. /*****************************************************************************/
  217.  
  218.  
  219.  
  220. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  221. /* See InitContent() for info. */
  222.  
  223. #pragma segment TheDoc
  224. OSErr    DialogInitContent(FileRecHndl frHndl, WindowPtr window)
  225. {
  226.     OSErr            err;
  227.     OSType            sftype;
  228.     ControlHandle    ctl;
  229.     Str255            pstr;
  230.  
  231.     sftype = (*frHndl)->fileState.sfType;
  232.     err = AddControlSet(window, sftype, kwStandardVis, 0, 0, nil);
  233.     if (sftype == 'ERR#') {
  234.         CNum2Ctl(window, 100, &ctl);
  235.         if (ctl) {
  236.             CTEGetPStr(ctl, pstr);
  237.             pcatdec(pstr, gDialogErr);
  238.             gDialogErr = noErr;
  239.             CTESetPStr(ctl, pstr);
  240.         }
  241.     }
  242.  
  243.     return(err);
  244. }
  245.  
  246.  
  247.  
  248. /*****************************************************************************/
  249.  
  250.  
  251.  
  252. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  253. /* See ResizeContent() for info. */
  254.  
  255. #pragma segment TheDoc
  256. void    DialogResizeContent(WindowPtr window, short oldh, short oldv)
  257. {
  258. #pragma unused (window, oldh, oldv)
  259. }
  260.  
  261.  
  262.  
  263. /*****************************************************************************/
  264.  
  265.  
  266.  
  267. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  268. /* See ScrollFrame() for info. */
  269.  
  270. #pragma segment TheDoc
  271. void    DialogScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv)
  272. {
  273. #pragma unused (frHndl, window, dh, dv)
  274. }
  275.  
  276.  
  277.  
  278. /*****************************************************************************/
  279.  
  280.  
  281.  
  282. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  283. /* See UndoFixup() for info. */
  284.  
  285. #pragma segment TheDoc
  286. void    DialogUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo)
  287. {
  288. #pragma unused (frHndl, contOrg, afterUndo)
  289.  
  290.     /* See DTS.Draw for an example of what you might do here. */
  291. }
  292.  
  293.  
  294.  
  295. /*****************************************************************************/
  296.  
  297.  
  298.  
  299. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  300. /* See WindowCursor() for info. */
  301.  
  302. #pragma segment TheDoc
  303. Boolean    DialogWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt)
  304. {
  305. #pragma unused (frHndl, window, globalPt)
  306.  
  307.     /* For examples of applications that have non-arrow cursor regions,
  308.     ** see DTS.Chat and DTS.Draw. */
  309.  
  310.     DoSetCursor(&qd.arrow);
  311.     return(true);
  312. }
  313.  
  314.  
  315.  
  316. /*****************************************************************************/
  317.  
  318.  
  319.  
  320. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  321. /* See WindowGoneFixup() for info. */
  322.  
  323. #pragma segment TheDoc
  324. void    DialogWindowGoneFixup(WindowPtr window)
  325. {
  326. #pragma unused (window)
  327. }
  328.  
  329.  
  330.  
  331. /*****************************************************************************/
  332. /*****************************************************************************/
  333. /*****************************************************************************/
  334.  
  335.  
  336.  
  337. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  338. /* See AdjustMenuItems() for info. */
  339.  
  340. #pragma segment TheDoc
  341. Boolean    DialogAdjustMenuItems(WindowPtr window, short menuID)
  342. {
  343. #pragma unused (window)
  344.  
  345.     if (menuID == mEdit)
  346.         CTEEditMenu(nil, mEdit, UnmapMItem(mEdit, kStdUndo), UnmapMItem(mEdit, kStdCut));
  347.  
  348.     return(false);
  349. }
  350.  
  351.  
  352.  
  353. /*****************************************************************************/
  354.  
  355.  
  356.  
  357. /* •• You don't call this.  DTS.Lib..framework does for appropriate document type(s). •• */
  358. /* See DoMenuItem() for info. */
  359.  
  360. #pragma segment TheDoc
  361. Boolean    DialogDoMenuItem(WindowPtr window, short menuID, short menuItem)
  362. {
  363. #pragma unused (window)
  364.  
  365.     return(DoMenuCommand(menuID, menuItem));
  366. }
  367.  
  368.  
  369.  
  370.